/**
 * Created by AllanXu on 01/03/2016.
 */
define(function (require) {
	var Vue = require('vue'),
		Config = require('config'),
		_ = require('ajax'),
		utilities = require('utilities');

    var qtid = sessionStorage.qtid;

	var app = new Vue({
		el: '#enroll_index',
		data: {
			renderObj: {},
			picServer: Config.picServer,
			member: {}
		},
		methods: {
			init: function () {
                _(Config.SERVICE.MATES.ENTOLL + '?id=' + qtid, {}, function (data) {
                    app.member = data.obj;
                });
			},
			go: function (url) {
				location.href = url;
			}
		}
	});
	app.init();

    //头像上传
    $('#pic').AjaxFileUpload({
        action: Config.SERVICE.USERCENTER.AVATARUPLOAD,
        onComplete: function (filename, response) {
            console.log(response.url);
            // console.log(url);
            _(Config.SERVICE.ACTIVITY.ENROLLSAVE, {
                "id": sessionStorage.qtid,
                "enroll.photo": 'http://www.qqlian.org'+response.url
            }, function (data) {
                if (data.code == 200) {
                    alert("头像上传成功~");
                    //utilities.refreshUserInfo(function (data) {
                        location.reload();
                    //});
                }
            });
        }
    });

});
